<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt"  uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <!--公共样式-->
    <link href="${pageContext.request.contextPath }/web/css/font/iconfont.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath }/web/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/NormalizeFile.css" />
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/public.css" />
    <!--列表页面私有样式-->
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/web/css/subpage/person.css" />
</head>
<body class="w928">
    <!--修改密码-->
    <div class="right-content bor1">
         <div class="bor1-t xx-top">
            <spring:message code="changePassword.changePassword"></spring:message>
        </div>
        <form id="form6" action="javascript:void(0)">
        <div class="pass-content">
            <ul>
                <li>
                    <span><spring:message code="changePassword.originalPassword"></spring:message>：</span>
                    <input type="password" id="passwordRaw" name="passwordRaw" class="input-modify" minlength="6" maxlength="15" placeholder="<spring:message code="changePassword.pleaseEnterTheOriginalPassword"></spring:message>"/>
                </li>
                <li>
                    <span><spring:message code="changePassword.newPassword"></spring:message>：</span>
                    <input type="password" id="password" name="password" onkeyup="value=value.replace(/[^A-Za-z0-9]/,'')" class="input-modify" minlength="6" maxlength="15" placeholder="<spring:message code="changePassword.pleaseEnterANewPassword"></spring:message>"/>
                </li>
                <li>
                    <span><spring:message code="changePassword.confirmNewPassword"></spring:message>：</span>
                    <input type="password" id="zpassword" name="zpassword" class="input-modify" onkeyup="value=value.replace(/[^A-Za-z0-9]/,'')" minlength="6" maxlength="15" placeholder="<spring:message code="changePassword.pleaseEnterANewPasswordAgain"></spring:message>"/>
                </li>
            </ul>
            <input type="button" class="btn-red" onclick="modifySubmit();" value="<spring:message code="changePassword.submit"></spring:message>" />
        </div>
        </form>
    </div>
<!--全局-->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/public.js"></script>
<!--ie789下placeholder不兼容-->
<script type="text/javascript" src="${pageContext.request.contextPath }/h-ui/lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/placeholder.js"></script>
<!--用户中心-->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/subpage/person.js"></script>
<!--异步提交表单  -->
<script type="text/javascript" src="${pageContext.request.contextPath }/web/js/jquery-form.js"></script>
<script type="text/javascript">
//提交修改密码
function modifySubmit(){
	var pass=document.getElementById("passwordRaw").value;
	var word=document.getElementById("zpassword").value;
	var pass1=document.getElementById("password").value;
	var password='';
	if(pass=='') {
		parent.layer.msg('<spring:message code="modifyPassword.originalPassword"></spring:message>',{icon:0,time:1000});
		return false;
	}else{
		$.ajax({
			type:"POST",
			url:"${pageContext.request.contextPath }/member/member/checkPassword",
			data:{
				passwordRaw:pass
			},
			success:function(data){
				if(data ==2){
					parent.layer.msg('<spring:message code="modifyPassword.passwordMistake"></spring:message>',{icon:0,time:1000});
					$("#passwordRaw").focus();
					return false;
				}
				if(data ==1){
					if(pass1=='') {
						parent.layer.msg('<spring:message code="modifyPassword.PasswordCannotEmpty"></spring:message>',{icon:0,time:1000});
						$("#password").focus();
						return false;
					}else if(pass1.length<6){
						parent.layer.msg('<spring:message code="modifyPassword.passwordLength"></spring:message>',{icon:0,time:1000});
						$("#password").focus(); 
						return false;
					}else if(pass1.length>15){
						parent.layer.msg('<spring:message code="modifyPassword.passwordTooLong"></spring:message>',{icon:0,time:1000});
						$("#password").focus(); 
						return false;
					}else{
						if(word == ""){
							parent.layer.msg('<spring:message code="modifyPassword.confirm"></spring:message>',{icon:0,time:1000});
							 $("#zpassword").focus();
							 return false;
						 }
						 if(pass1!=word) {
							 parent.layer.msg('<spring:message code="modifyPassword.equally"></spring:message>',{icon:0,time:1000});
							 $("#zpassword").focus();
							  return false;
						  }else{
							  password+=$("#password").val(); 
							  $('#form6').ajaxSubmit({
									type:"POST",
									url:"${pageContext.request.contextPath }/member/member/changePassword",
									success:function(data){
										if(data!=1){
											parent.layer.msg('<spring:message code="modifyPassword.fail"></spring:message>',{icon:0,time:1000});
										}else{
											parent.layer.msg('<spring:message code="modifyPassword.success"></spring:message>',{icon:1,time:1000});
											window.setTimeout("top.location.href='${pageContext.request.contextPath }/web/member/login'",2000);
										}
								} 
						   });
						  }
					}
				}
				
			}
		});
	}

} 
</script>
</body>
</html>